package com.example.nio.filechannel;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;

/**
 * @author panghu
 * @version 1.0.0
 * @createTime 2023年08月06日 15:20:00
 * @Description
 */
public class Demo07 {

    public static void main(String[] args) throws IOException {
        try(FileOutputStream out = new FileOutputStream("test2.txt");
            FileInputStream in = new FileInputStream("test.txt")){

            FileChannel inChannel = in.getChannel();   //获取到test文件的通道
            // 我来接受什么
            out.getChannel().transferFrom(inChannel, 0, inChannel.size());   //直接将从test文件通道中传来的数据转给test2文件的通道
        }
    }

}
